<template>
  <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
    <el-radio-button :label="false">展开</el-radio-button>
    <el-radio-button :label="true">收起</el-radio-button>
  </el-radio-group>
  <el-menu :collapse="isCollapse"
           class="el-menu-vertical-demo" router
           :default-active="this.$route.fullPath">
    <el-menu-item :key="0"
                  :index="'/analysis/detail?questionnaireId=' + this.$route.query.questionnaireId"
                  @click="analysisSelect">
      <i class="el-icon-menu"></i>
      <template #title>普通分析</template>
    </el-menu-item>
    <el-menu-item :key="1"
                  :index="'/analysis/cross?questionnaireId=' + this.$route.query.questionnaireId"
                  @click="crossSelect">
      <i class="el-icon-data-line"></i>
      <template #title>交叉分析</template>
    </el-menu-item>
    <el-menu-item :key="2"
                  :index="'/analysis/download?questionnaireId=' + this.$route.query.questionnaireId"
                  @click="downloadSelect">
      <i class="el-icon-download"></i>
      <template #title>答卷下载</template>
    </el-menu-item>

  </el-menu>
</template>


<script>
export default {
  name: "NavBar",
  beforeMount() {
    this.$router.push('/analysis/detail?questionnaireId=' + this.$route.query.questionnaireId)
  },
  data() {
    return {
      isCollapse: false,
    }
  },
  emits: ['downloadClick', 'analysisClick', 'crossClick'],
  methods: {
    downloadSelect() {
      this.$emit('downloadClick')
    },
    analysisSelect() {
      this.$emit('analysisClick')
    },
    crossSelect() {
      this.$emit('crossClick')
    }
  }
}
</script>

<style scoped>

.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>